<template>
    <a-spin :spinning="spinning">
      <div class="main">
        <a-card title="查看档案详情" :loading="loading">
          <div style="display:flex">
            <a-form-model :model="form" style="width:calc(100% - 300px)" labelAlign="right" :rules="rules" ref="ruleForm"
              :labelCol="{ span: 10 }" :wrapperCol="{ span: 14 }">
              <a-row>
                <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" :xxl="24">
                  <div style="display: flex;justify-content: flex-start;vertical-align: middle;align-items: center">
                    <h3 style="color: #969799;">基础档案</h3>
                  </div>
                </a-col>
                <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                  <a-form-model-item label="产品编号">
                    {{ form.sccode }}
                  </a-form-model-item>
                </a-col>
                <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                  <a-form-model-item label="产品大类" prop="scdl">
                    {{form.scdlValue}}
                  </a-form-model-item>
                </a-col>
                <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                  <a-form-model-item label="产品小类" prop="scxl">
                    {{form.scxlValue}}
                  </a-form-model-item>
                </a-col>
                <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6" v-if="!showProcess">
                  <a-form-model-item label="产品细分">
                   {{form.scxflValue }}
                  </a-form-model-item>
                </a-col>
                <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                  <a-form-model-item label="产品名称" prop="scname">
                    {{form.scname}}
                  </a-form-model-item>
                </a-col>
                <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                  <a-form-model-item label="厂家编号">
                    {{form.sccshh}}
                  </a-form-model-item>
                </a-col>
                <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                  <a-form-model-item label="供应厂商" prop="scsupid">
                   {{form.scsupName}}
                  </a-form-model-item>
                </a-col>
                <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                  <a-form-model-item label="放样周期">
                   {{form.scvc1}}
                  </a-form-model-item>
                </a-col>
                <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                  <a-form-model-item label="大货周期">
                    {{form.scdhpricetype}}
                  </a-form-model-item>
                </a-col>
                <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                  <a-form-model-item label="对应上货季">
                   {{ form.scseasonValue }}
                  </a-form-model-item>
                </a-col>
                <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                  <a-form-model-item label="起订数量">
                    {{form.scmoq}}
                  </a-form-model-item>
                </a-col>
                <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                  <a-form-model-item label="关联编号">
                    {{form.screlation}}
                  </a-form-model-item>
                </a-col>
                <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                  <a-form-model-item label="关联类型">
                  {{form.screlationtype}}
                  </a-form-model-item>
                </a-col>
                <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="8" :xxl="6">
                <a-form-model-item label="产品备注">
                  {{form.scmemo}}
                </a-form-model-item>
              </a-col>
                <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="12" :xxl="12">
                {{form.scmemo}}
                </a-col>
                <div v-if="showProcess">
                  <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" :xxl="24">
                    <div style="display: flex;justify-content: flex-start;vertical-align: middle;align-items: center">
                      <h3 style="color: #969799;">加工属性</h3>
                    </div>
                  </a-col>
                  <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                    <a-form-model-item label="是否再加工" prop="scisprocess">
                        <span v-if="form.scisprocess == 'Y'"> 是</span>
                        <span v-if="form.scisprocess == 'N'"> 否</span>
                    </a-form-model-item>
                  </a-col>
                  <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6" v-if="form.scisprocess == 'Y'">
                    <a-form-model-item label="加工类型" prop="scprocesstype">
                     {{ scprocesstypeValue }}
                    </a-form-model-item>
                  </a-col>
  
                  <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6" v-if="form.scisprocess == 'Y'">
                    <a-form-model-item label="底/面编号">
                      {{form.sclowercode}}
                    </a-form-model-item>
                  </a-col>
                  <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                    <a-form-model-item label="底布名称">
                      {{form.sclowername}}
                    </a-form-model-item>
                  </a-col>
                  <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6" v-if="form.scisprocess == 'N'">
                    <a-form-model-item label="底布小类">
                     {{form.sclowersmalltype}}
                    </a-form-model-item>
                  </a-col>
                  <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                    <a-form-model-item label="底布细分">
                   {{ form.lowerminismalltypeValue }}
                    </a-form-model-item>
                  </a-col>
                  <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                    <a-form-model-item label="其他底布">
                      {{form.sclowerothers}}
                    </a-form-model-item>
                  </a-col>
                </div>
                <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" :xxl="24">
                  <div style="display: flex;justify-content: flex-start;vertical-align: middle;align-items: center">
                    <h3 style="color: #969799;">产品规格</h3>
                  </div>
                </a-col>
                <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                  <a-form-model-item label="产品成分" prop="sccf">
                    {{form.sccf}}
                  </a-form-model-item>
                </a-col>
                <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                  <a-form-model-item label="有效门幅" prop="scmf">
                    {{form.scmf}}
                  </a-form-model-item>
                </a-col>
                <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                  <a-form-model-item label="平方克重(g/㎡)" prop="scmlkz">
                    {{form.scmlkz}}
                  </a-form-model-item>
                </a-col>
                <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                  <a-form-model-item label="产品规格">
                    {{form.scspec}}
                  </a-form-model-item>
                </a-col>
                <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" :xxl="24">
                  <div style="display: flex;justify-content: flex-start;vertical-align: middle;align-items: center">
                    <h3 style="color: #969799;">产品价格</h3>
                  </div>
                </a-col>
                <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                  <a-form-model-item label="产品单价">
                   {{form.scprice}}
                  </a-form-model-item>
                </a-col>
                <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                  <a-form-model-item label="标化单价">
                    <!-- <a-input placeholder="" v-model="form.bhprice" :disabled="true" /> -->
                    {{  form.bhprice}}
                  </a-form-model-item>
                </a-col>
                <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                  <a-form-model-item label="核价成本">
                    {{form.schj}}
                  </a-form-model-item>
                </a-col>
                <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                  <a-form-model-item label="大货单价">
                   {{form.scdhprice}}
                  </a-form-model-item>
                </a-col>
                <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                  <a-form-model-item label="底布单价">
                   {{form.scyhprice}}
                  </a-form-model-item>
                </a-col>
                <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                  <a-form-model-item label="小品牌价格">
                   {{form.scprice1}}
                  </a-form-model-item>
                </a-col>
                <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                  <a-form-model-item label="特殊单价">
                    {{form.scsyn01}}
                  </a-form-model-item>
                </a-col>
                <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                  <a-form-model-item label="价格单位">
                    {{form.scpricetype}}
                  </a-form-model-item>
                </a-col>
                <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12" :xxl="12">
                  <a-form-model-item label="阶梯价格" :labelCol="{ span: 5 }" :wrapperCol="{ span: 17 }">
                    {{form.scdhpricememo}}
                  </a-form-model-item>
                </a-col>
                <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" :xxl="24">
                  <div style="display: flex;justify-content: flex-start;vertical-align: middle;align-items: center">
                    <h3 style="color: #969799;">关键指标</h3>
                  </div>
                </a-col>
                <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                  <a-form-model-item label="合同缩率">
                    {{ form.scmlsl }}
                  </a-form-model-item>
                </a-col>
                <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                  <a-form-model-item label="排料缩率">
                   {{form.scmlsl1}}
                  </a-form-model-item>
                </a-col>
                <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                  <a-form-model-item label="扭曲率">
                    {{form.sctwistrate}}
                  </a-form-model-item>
                </a-col>
                <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                  <a-form-model-item label="成衣洗涤" prop="scgy">
                   {{form.scgyValue}}
                  </a-form-model-item>
                </a-col>
                <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                  <a-form-model-item label="产品外观">
                    {{form.scappearanceValue}}
                  </a-form-model-item>
                </a-col>
                <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                  <a-form-model-item label="布面效果">
                   {{form.sceffectValue}}
  
                  </a-form-model-item>
                </a-col>
                <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                  <a-form-model-item label="面料特性">
                  {{ form.scqualityValue }}
                  </a-form-model-item>
                </a-col>
                <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                  <a-form-model-item label="产品工艺">
                  {{ form.scfjgyValue }}
                  </a-form-model-item>
                </a-col>
                <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                  <a-form-model-item label="排版要求">
                   {{form.scshksValue}}
  
                  </a-form-model-item>
                </a-col>
                <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                  <a-form-model-item label="产品弹力">
                   {{form.scelasticValue}}
                  </a-form-model-item>
                </a-col>
                <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                  <a-form-model-item label="硬挺度">
                   {{ form.scstiffnessValue }}
                  </a-form-model-item>
                </a-col>
                <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                  <a-form-model-item label="损耗率">
                   {{form.scn1}}
                  </a-form-model-item>
                </a-col>
                <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" :xxl="24">
                  <div style="display: flex;justify-content: flex-start;vertical-align: middle;align-items: center">
                    <h3 style="color: #969799;">推广属性</h3>
                  </div>
                </a-col>
  
                <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                  <a-form-model-item label="环保标签">
                    {{form.scoriginarea}}
                  </a-form-model-item>
                </a-col>
                <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                  <a-form-model-item label="进口产地">
                   {{form.scimportareaValue}}
                  </a-form-model-item>
                </a-col>
                <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                  <a-form-model-item label="原料产地">
                    {{form.scenvironmentalValue}}
                  </a-form-model-item>
                </a-col>
                <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                  <a-form-model-item label="服用功能">
                   {{form.scfzytValue}}
                  </a-form-model-item>
                </a-col>
                <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                  <a-form-model-item label="高档材料">
                   {{form.scseniormaterialValue}}
                  </a-form-model-item>
                </a-col>
                <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                  <a-form-model-item label="材料等级">
                    {{ form.scmateriallevelValue }}
                  </a-form-model-item>
                </a-col>
                <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="24" :xxl="24">
                  <div style="display: flex;justify-content: flex-start;vertical-align: middle;align-items: center">
                    <h3 style="color: #969799;">其他属性</h3>
                  </div>
                </a-col>
                <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                  <a-form-model-item label="图案编号">
                    {{form.scpiccode}}
                  </a-form-model-item>
                </a-col>
                <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                  <a-form-model-item label="图案名称">
                    {{ form.scpicName }}
                  </a-form-model-item>
                </a-col>
                <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                  <a-form-model-item label="商检成分">
                    {{ form.composition }}
                  </a-form-model-item>
                </a-col>
                <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6" v-if="form.sccode">
                  <a-form-model-item label="制单人">
                    {{ form.sccreator }}
                  </a-form-model-item>
                </a-col>
                <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6" v-if="form.sccode">
                  <a-form-model-item label="制单日期">
                    {{ form.updatedate }}
                  </a-form-model-item>
                </a-col>
                <a-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8" :xxl="6">
                  <a-form-model-item label="档存编号">
                   {{form.scdesignbill}}
                  </a-form-model-item>
                </a-col>
  
              </a-row>
  
  
            </a-form-model>
            <div style="width:300px;padding: 35px 20px;">
              <img :src="form.schavpict" alt="form.schavpict" style="width:290px">
              <div style="width:290px">
                产品风险评估:{{ form.scriskassessment }}
              </div>
              <div style="width:290px;margin-top: 30px;">
                产品推广资料:{{ form.scpopularize }}
              </div>
              <div style="display:flex;width: 300px;margin-top: 30px;">是否推荐：
                <span v-if="form.scisrecommend == 'Y'">
                  是
                </span>
                <span v-if="form.scisrecommend == 'N'">
                  否
                </span>

              </div>
            </div>
  
          </div>
        </a-card>
        <a-card>
          <a-tabs :default-active-key="0" v-model="current" @change="changeTab">
            <a-tab-pane :key="0" tab="颜色">
            </a-tab-pane>
            <a-tab-pane :key="1" tab="产品缩率">
            </a-tab-pane>
            <a-tab-pane :key="2" tab="物料成分">
            </a-tab-pane>
          </a-tabs>
            <a-table bordered  v-show="current == 0" :columns="cloumn1" :pagination="false" style="margin-top:20px" :data-source="colorList"></a-table>
          <a-table v-show="current == 1" bordered :columns="cloumn3" :pagination="false" style="margin-top:20px" :data-source="minifiList"></a-table>
          <a-table v-show="current == 2" bordered :columns="cloumn2" :pagination="false" style="margin-top:20px" :data-source="groupList"> </a-table>
          <div style="display: flex;justify-content: flex-end;">
            <a-pagination v-model="pageNum" :total="total" :item-render="itemRender" :show-total="total => `共 ${total} 条记录`"
              :page-size="pageSize" show-quick-jumper @change="onChange" />
          </div>
        </a-card>
      </div>
    </a-spin>
  </template>
  
  <script>
  import color from './color.vue'
  import minifi from './minifi.vue'
  import group from './group.vue'
  import JImageUpload from './upload/JImageUpload.vue'
  import fileUpload from './upload/uploadfile.vue'
  import fileUpload1 from './upload/uploadfile1.vue'
  import fileUpload2 from './upload/uploadfile2.vue'
  import globalData from '@/assets/js/common'
  import { postAction } from '@/api/manage'
  import { axios } from '@/utils/request'
  import { seachSupply, getSampleInfo, getSampleColorList, getSampleMinifiList, getSampleGroupList, seachPattern, sampleUpdate, sampleAdd, saveMaterial, getDictChildList, getDetail, updateMaterial, uploadFiles, minifiList } from '@api/material/index'
  const cloumn1 = [
  {
    title: '序号',
    dataIndex: 'mcsx'
  },
  {
    title: '销售色',
    dataIndex: 'mcid'
  },
  {
    title: '销售色名称',
    dataIndex: 'mcname'
  },
  {
    title: '季节',
    dataIndex: 'mcseasonValue'
  },
  {
    title: '印花色',
    dataIndex: 'mcvc4'
  },
  {
    title: '备注',
    dataIndex: 'mcmemo'
  },
]
const cloumn2 = [
  {
    title: '序号',
    dataIndex: 'rowno'
  },
  {
    title: '成分',
    dataIndex: 'sccfValue',
  },
  {
    title: '占比',
    dataIndex: 'sccfbl',
    scopedSlots: { customRender: 'sccfbl' }
  },
]
const cloumn3 = [
  {
    title: '序号',
    dataIndex: 'cmRowid'
  },
  {
    title: '面料要求',
    dataIndex: 'cmTypeValue',
  },
  {
    title: '经缩率%',
    dataIndex: 'cmLongitude',
    scopedSlots: { customRender: 'cmLongitude' }
  },
  {
    title: '纬缩率%',
    dataIndex: 'cmLatitude',
    scopedSlots: { customRender: 'cmLatitude' }

  },
]
  export default {
    components: {
      color,
      minifi,
      group,
      JImageUpload,
      fileUpload,
      fileUpload1,
      fileUpload2
    },
    data() {
      return {
        cloumn1,
        cloumn2,
        cloumn3,
        sccode: '',
        patternCode: '',
        scdlList: [],
        scxlList: [],
        scxflList: [],
        scsupidList: [],
        scseasonList: [],
        scqualityList: [],
        scimportareaList: [],
        scgyList: [],
        appearanceList: [],
        effectList: [],
        elasticList: [],
        stiffnessList: [],
        environmentalList: [],
        seniormaterialList: [],
        materiallevelList: [],
        scfjgyList: [],
        scshksList: [],
        scfzytList: [],
        relationtypeList: [],
        processtypeList: [],
        lowercodeList: [],
        lowersmalltypeList: [],
        patternList: [],
        lowerminismallList: [],
        classifyMinimumList: [],
        putGoodsSeasonList: [],
        typeList: [],
        colorAttributeList: [],
        specialSuffixValueList: [],
        priceProgrammeList: [],
        supplyTypeList: [],
        spinning: false,
        taxRate: '',
        current: 0,
        urlKey: 'basemgt-material/',
        form: {
          flag3d: "",
          platformid: "",
          jobnumber: '',
          sampleClothGroupDTOList: [],
          sampleClothMatColorDTOList: [],
          sampleClothMinificationDTOList: [],
          scc130: "",
          scxfl: undefined,
          screlation: '',
          scmoq:'',
          screlationtype: undefined,
          scisprocess: undefined,
          scprocesstype: undefined,
          sclowercode: undefined,
          scappearance: undefined,
          sceffect: undefined,
          scelastic: undefined,
          scstiffness: undefined,
          scenvironmental: undefined,
          scseniormaterial: undefined,
          scmateriallevel: undefined,
          sclowersmalltype: undefined,
          scoriginarea: '',
          sctwistrate: '',
          sclowername: '',
          sclowerothers: '',
          scdhpricetype: '',
          scyhprice: '',
          sccf: "",
          sccjsh: "",
          sccode: "",
          sccreatdate: "",
          sccshh: "",
          sccw: "",
          scdesignbill: "",
          scdhprice: "",
          scdhpricememo: "",
          scdhpricetype: "",
          scdl: undefined,
          scfjgy: undefined,
          scfsfs: "",
          scfzyt: undefined,
          scgy: undefined,
          scgymain: "",
          schavpict: "",
          schj: '',
          scimportarea: undefined,
          scisrk: "",
          sckcsl: 0,
          bhprice:'',
          scmatertype1: "",
          scmatertype2: "",
          scmemo: "",
          scmf: "",
          scmlkz: "",
          scmlsl: "",
          scmlsl1: "",
          scn1: '',
          scname: "",
          lowerminismalltype: undefined,
          scpiccode: undefined,
          scpicName: '',
          scprice: '',
          scprice1: '',
          scpricetype: "",
          scquality: undefined,
          scseason: undefined,
          scshks: undefined,
          scsupid: undefined,
          scsyn01: "",
          scvc1: "",
          scxl: undefined,
          scpopularize: '',
          scriskassessment: '',
        },
        rules: {
          scdl: [{ required: true, message: '请选择产品大类', trigger: 'change' }],
          scxl: [{ required: true, message: '请选择产品小类', trigger: 'change' }],
          scname: [{ required: true, message: '请输入产品名称', trigger: 'change' }],
          scsupid: [{ required: true, message: '请选择供应厂商', trigger: 'change' }],
          scisprocess: [{ required: true, message: '请选择是否再加工', trigger: 'change' }],
          scprocesstype: [{ required: true, message: '请选择加工类型', trigger: 'change' }],
          sccf: [{ required: true, message: '请输入产品成分', trigger: 'change' }],
          scmf: [{ required: true, message: '请输入有效门幅', trigger: 'change' }],
          scmlkz: [{ required: true, message: '请输入平方克重', trigger: 'change' }],
          scgy: [{ required: true, message: '请选择成衣洗涤', trigger: 'change' }],
        },
        showProcess: false,
        colorList: [],
        minifiList: [],
        groupList: [],
        filePath1: [],
        fileList1: [],
        filePath2: [],
        filePath3: [],
        schavpict: [],
        total: 0,
        pageNum: 1,
        pageSize: 10,
        itemRender: (current, type, originalElement) => {
          if (type === 'prev') {
            return <a>上一页</a>
          } else if (type === 'next') {
            return <a>下一页</a>
          }
          return originalElement
        },
        priceList: [],
        supplyList: [],
        showSupply: false,
        showPrice: false,
        showCopy: false,
        loading: false,
        supplyDetail: {},
        supplyIndex: null,
        showPrint: false,
        showSelect: false,
        printType: '',
        priceProgramme: '',
        list: [],
        supplyCode: '',
        newLifePhotos: [],
        disabled: false,
        current: 0,
        ifChange: false
      }
    },
    watch: {
      // sccode(newVal, oldVal) {
      //   if (newVal && newVal !== oldVal) {
      //     this.loadAcc(newVal)
      //   }
      // },
    },
    created() { },
    computed: {
      jobNumber() {
        return this.$store.getters.userInfo.workNo || ''
      },
      userInfo() {
        return this.$store.getters.userInfo || null
      }
    },
    mounted() {
      this.loadData()
      if (this.$route.query.sccode) {
        this.sccode = this.$route.query.sccode
        this.$nextTick(() => {
          this.loadAcc(this.sccode)
          this.loadColor()
          // this.loadminifi()
          // this.loadgroup()
          // this.loadAccSpecs()
        })
      }
    },
    methods: {
      filterOption(input, option) {
        if (option && option.props && option.props.title) {
          return option.props.title === input || option.props.title.indexOf(input) !== -1
        } else {
          return true
        }
      },
      changeTab() {
        this.pageNum = 1
        if (this.current == 0) {
          this.loadColor()
        } else if (this.current == 1) {
          this.loadminifi()
        } else {
          this.loadgroup()
        }
      },
      onChange() {
        if (this.current == 0) {
          this.loadColor()
        } else if (this.current == 1) {
          this.loadminifi()
        } else {
          this.loadgroup()
        }
      },
      async getScsupidList(value) {
        const res = await seachSupply({ keyWord: value })
        if (res.code == 200) {
          this.scsupidList = res.data
        } else {
          if (res.msg) {
            this.$message.error(res.msg)
          } else {
            this.$message.error('获取供应商列表失败！')
          }
        }
      },
      async getPatternList(value) {
        const res = await seachPattern({ keyWord: value })
        if (res.code == 200) {
          this.patternList = res.data
        } else {
          if (res.msg) {
            this.$message.error(res.msg)
          } else {
            this.$message.error('获取图案列表失败！')
          }
        }
      },
      async loadLowercode() {
        const res = await getSampleInfo({ sccode: this.form.sclowercode })
        if (res.code == 200) {
          this.form.sclowername = res.data.scname
          this.form.sclowersmalltype = res.data.scxl
          this.changeLowersmalltype()
        } else {
          if (res.msg) {
            this.$message.error(res.msg)
          } else {
            this.$message.error('查找底布失败！')
          }
        }
      },
      changeIsprocess() {
        this.form.scprocesstype = undefined
        this.form.sclowercode = ''
        this.form.sclowername = ''
        this.form.sclowersmalltype = undefined
      },
      loadData() {
        this.getDictChildList('PRODUCT_BIGTYPE', 'scdlList')
        this.getScsupidList()
        this.getPatternList()
      },
      async getDictChildList(name, list, id) {
        if (!this[list].length || (this[list].length && id)) {
          const params = {
            name: name,
            parentId: id
          }
          try {
            const res = await getDictChildList(params)
            if (res.code == 200) {
              this[list] = res.data
            } else {
              if (res.msg) {
                this.$message.error(res.msg)
              } else {
                this.$message.error('获取数据字典失败！')
              }
            }
          } catch (error) {
            this.$message.error('获取数据字典失败！')
          }
        }
        if (this.processtypeList.length) {
          this.showProcess = true
        } else {
          this.showProcess = false
        }
        if (name == 'PRODUCT_BIGTYPE' && this.form.scdl && this.scdlList.length) {
          this.scdlList.map(item => {
            if (item.code == this.form.scdl) {
              this.getDictChildList('PRODUCT_SMALLTYPE', 'scxlList', item.id)
            }
          })
        }
        if (name == 'PRODUCT_SMALLTYPE' && this.form.scxl && this.scxlList.length) {
          this.scxlList.map(item => {
            if (item.code == this.form.scxl) {
              this.getDictChildList('PRODUCT_MINISMALLTYP', 'scxflList', item.id)
              this.getDictChildList('PRODUCT_TECHNOLOGY', 'processtypeList', item.id)
            }
          })
        }
      },
      changeBig() {
        this.form.scxl = undefined
        if (this.scdlList) {
          this.scdlList.map(item => {
            if (item.code == this.form.scdl) {
              this.getDictChildList('PRODUCT_SMALLTYPE', 'scxlList', item.id)
            }
          })
        }
      },
      changeSmall() {
        this.form.scxfl = undefined
        this.form.scprocesstype = undefined
        this.processtypeList = []
        if (this.scxlList) {
          this.scxlList.map(item => {
            if (item.code == this.form.scxl) {
              this.getDictChildList('PRODUCT_MINISMALLTYP', 'scxflList', item.id)
              this.getDictChildList('PRODUCT_TECHNOLOGY', 'processtypeList', item.id)
            }
          })
        }
      },
      changeLowersmalltype() {
        this.form.lowerminismalltype = undefined
        if (this.scxlList) {
          this.scxlList.map(item => {
            if (item.code == this.form.sclowersmalltype) {
              this.getDictChildList('PRODUCT_MINISMALLTYP', 'lowerminismallList', item.id)
            }
          })
        }
      },
      changeSeniormaterial() {
        this.form.scmateriallevel = undefined
        if (this.seniormaterialList) {
          this.seniormaterialList.map(item => {
            if (item.code == this.form.scseniormaterial) {
              this.getDictChildList('PRODUCT_MATERIALLEVEL', 'materiallevelList', item.id)
            }
          })
        }
      },
      changePattern() {
        this.patternCode = this.form.scpiccode
        this.form.scpicName = ''
        console.log(this.patternList);
        if (this.patternList) {
          this.patternList.map(item => {
            if (item.patternCode == this.form.scpiccode) {
              this.form.scpicName = item.patternName
            }
          })
        }
      },
      getLittle() {
  
      },
      getSmall() {
        if (this.form.classifyBig) {
          this.classifyBigList.map(item => {
            if (item.code == this.form.classifyBig) {
              this.getDictChildList('PRODUCT_SMALLTYPE', 'scxlList', item.id)
            }
          })
        }
      },
      getMin() {
        this.getDictChildList('CLASSIFY_MINIMUM', 'classifyMinimumList')
      },
      getModel(name, list) {
        if (this.form.scxl) {
          this.scxlList.map(item => {
            if (item.code == this.form.scxl) {
              this.getDictChildList(name, list, item.id)
            }
          })
        }
      },
      handleCancel() {
        this.showSelect = false
      },
      handleOk() {
        if (this.printType) {
          this.showSelect = false
          this.showPrint = true
        } else {
          this.$message.warning('请先选择打印类型！')
        }
      },
      getUploadParams() {
        return { ...globalData.uploadParams }
      },
      fileChange(list) {
        if (list.length) {
          this.form.schavpict = list[0].url
        } else {
          this.form.schavpict = ''
        }
        this.newLifePhotos = list
  
      },
      fileChange1(list) {
        this.fileList1 = list
        console.log(this.fileList1);
      },
      fileChange2(list) {
        this.fileList2 = list
      },
      fileChange3(list) {
        this.fileList3 = list
      },
      async saveFile(type) {
        const formData = new FormData()
        if (type == 1) {
          this.fileList1.forEach((file) => {
            formData.append(`files`, file.originFileObj);
          });
        } else if (type == 2) {
          this.fileList2.forEach((file) => {
            formData.append(`files`, file.originFileObj);
          });
        } else {
          this.fileList3.forEach((file) => {
            formData.append(`files`, file.originFileObj);
          });
        }
        formData.append('sccode', this.sccode)
        formData.append('type', type)
        const apiBaseUrl = window._CONFIG['domianURL'] || "/jeecg-boot";
        axios({
          url: apiBaseUrl + '/api/gateway/basemgt-material/sample-upload-file/uploadFiles',
          method: 'post',
          data: formData,
          contentType: false,
          cache: false,
          processData: false,//用于对data参数进行序列化处理 这里必须false
          // headers: { 'Content-Type': 'multipart/form-data; boundary=----WebKitFormBoundarynl6gT1BKdPWIejNq' }
        }).then(res => {
          if (res.code == 200) {
            this.$message.success('保存成功')
          } else {
            this.$message.warning(res.msg || '操作失败')
          }
          this.loading = false
        })
  
      },
      changeColor() {
        this.loadColor()
      },
      changeminifi() {
        this.loadminifi()
      },
      changegroup() {
        this.loadgroup()
      },
  
      changeSupply(supplyList) {
        this.form.accSupplyList = supplyList
        if (this.form.priceProgramme == 'ZIPPER') {
          this.ifChange = true
        }
      },
      async loadColor() {
        const params = {
          sccode: this.sccode,
          size: this.pageSize,
          pageNo: this.pageNum
        }
        try {
          const res = await getSampleColorList(params)
          if (res.code == 200) {
            this.colorList = res.data.records
            this.total = res.data.total
          } else {
            if (res.msg) {
              this.$message.error(res.msg)
            } else {
              this.$message.error('获取颜色列表失败！')
            }
          }
        } catch (error) {
          this.$message.error('获取颜色列表失败！')
        }
      },
      async loadminifi() {
        const params = {
          sccode: this.sccode,
          size: this.pageSize,
          pageNo: this.pageNum
        }
        try {
          const res = await getSampleMinifiList(params)
          if (res.code == 200) {
            this.minifiList = res.data.records
            this.total = res.data.total
          } else {
            if (res.msg) {
              this.$message.error(res.msg)
            } else {
              this.$message.error('获取缩率列表失败！')
            }
          }
        } catch (error) {
          this.$message.error('获取缩率列表失败！')
        }
      },
      async loadgroup() {
        // this.form.sccf = ''
        const params = {
          sccode: this.sccode,
          size: this.pageSize,
          pageNo: this.pageNum
        }
        try {
          const res = await getSampleGroupList(params)
          if (res.code == 200) {
            this.groupList = res.data.records
            // if(this.groupList.length){
            //   this.form.sccf = this.groupList[0].sccfValue
            // }   
            this.total = res.data.total
          } else {
            if (res.msg) {
              this.$message.error(res.msg)
            } else {
              this.$message.error('获取成分列表失败！')
            }
          }
        } catch (error) {
          this.$message.error('获取成分列表失败！')
        }
      },
      onSubmit() {
        this.$refs.ruleForm.validate(valid => {
          if (valid) {
            this.save()
          } else {
            console.log('error submit!!')
            return false
          }
        })
      },
      async save() {
        this.spinning = true
        try {
          this.form.jobnumber = this.jobNumber
          this.form.sccreator = this.userInfo.realname
          let res = this.form.sccode ? await sampleUpdate(this.form) : await sampleAdd(this.form)
          if (res.code == 200) {
            this.$message.success('保存成功！')
            if (!this.form.sccode) {
              this.form.sccode = res.data.msg
            }
            this.$nextTick(() => {
              this.loadAcc(this.form.sccode)
            })
          } else {
            if (res.msg) {
              this.$message.error(res.msg)
            } else {
              this.$message.error('保存失败！')
            }
  
          } this.spinning = false
        } catch (error) {
          this.spinning = false
  
          this.$message.error('保存失败！')
        }
      },
      async loadAcc(sccode) {
        this.loading = true
        this.schavpict = []
        try {
          const res = await getSampleInfo({ sccode: sccode })
          if (res.code == 200) {
            this.form = res.data
            if(res.data.schavpict){
              this.schavpict.push(res.data.schavpict)
            }
            if (res.data.scpiccode) {
              this.changePattern()
            }
          } else {
            if (res.msg) {
              this.$message.error(res.msg)
            } else {
              this.$message.error('获取列表详情失败！')
            }
            this.disabled = true
          }
          this.loading = false
        } catch (error) {
          this.loading = false
          this.disabled = true
        }
      },
      sync(values) {
        this.supplyList.map(item => {
          if (item.supplyCode == values.supplyCode) {
            item.defaultStatus = 1
            this.accPriceList = item.accPriceList
          } else {
            item.defaultStatus = 0
          }
        })
      },
      closePrice(supplyCode, list) {
        this.showPrice = false
        if (list) {
          this.supplyList.map(item => {
            if (item.supplyCode == supplyCode) {
              item.accPriceList = list
              if (item.defaultStatus == 1) {
                this.accPriceList = list
              }
            }
          })
          this.form.accSupplyList = this.supplyList
        }
      }
    }
  }
  </script>
  <style>
  .tableHiddle {
    display: none;
  }
  
  .tableShow {
    display: revert;
  }
  </style>